Unit BDojoListenerUnit;

{$mode objfpc}{$H+}

Interface

Uses
  Classes, SysUtils, fgl;

Type BProcedureClass = Procedure of Object;

Type

{ BDojoListenerClass }

 BDojoListenerClass = Class
  Private
    bJSEvent: String;
    bJSName: String;
    bMethod: BProcedureClass;
    bToken: Integer;
  Public
    Property JSName: String Read bJSName;
    Property JSEvent: String Read bJSEvent;
    Property Method: BProcedureClass Read bMethod;
    Property Token: Integer Read bToken;

    Function Execute(Const aJSName, aJSEvent: String;
      Const aToken: Integer): Boolean;

    Constructor Build(Const aJSName, aJSEvent: String;
      Const aMethod: BProcedureClass);
    Destructor Burn;
End;

Type BDojoListenersList = Specialize TFPGList<BDojoListenerClass>;

Implementation

{ BDojoListenerClass }

Function BDojoListenerClass.Execute(Const aJSName, aJSEvent: String;
  Const aToken: Integer): Boolean;
Begin
  If (bToken = aToken) And (bJSName = aJSName) And (bJSEvent = aJSEvent)Then
    bMethod;
End;

Constructor BDojoListenerClass.Build(Const aJSName, aJSEvent: String;
  Const aMethod: BProcedureClass);
Begin
  bJSName := aJSName;
  bJSEvent := aJSEvent;
  bMethod := aMethod;
  bToken := Random(10000000); // why not ^_^
End;

Destructor BDojoListenerClass.Burn;
Begin

End;

End.

